/**
 * Created by WT on 2017/4/5.
 */
$(function () {
    var isMulti = $.getQueryParam('isMulti');
    var singleSelect = 0;
    if (isMulti && isMulti.toString() === '1') {
        singleSelect = 1;
    }
    debugger
    //初始化加载datagrid
    $('#dg1').datagrid({
        method: 'post',
        url: ROOT_PATH + '/threeSimultaneities/projectInfo/getList.shtml',
        queryParams: {
            sort: 'd.addTime',
            order: 'desc',
            pal:singleSelect
        },
        toolbar: '#toolbar',
        fitColumns: true,
        pagination: true,
        pageSize: 10,
        rownumbers: true,
        sortOrder: true,
        striped: true,
        fit: true,
        singleSelect: true,
        columns: [[
            {field: 'id', checkbox: true},
            {field: 'code', title: '项目编号', width: 100},
            {field: 'name', title: '项目名称', width: 100},
            {field: 'shortName', title: '项目简称', width: 100},
            {field: 'projectType', title: '项目类别', width: 100},
            {field: 'deptName', title: '所属部门', width: 100}
        ]]
    });
    $('#btn_clear').on("click", function () {
        $('#tb1').form('reset');
    });
    $('#btn_search').on("click", function () {
        var queryParams = $('#tb1').find(':input').serializeJson();
        queryParams["sort"] = 'd.addTime';
        queryParams["order"] = 'desc';
        $('#dg1').datagrid('load', queryParams);
    });
    $('#btn_save').on("click", function () {
        var $selected = $('#dg1').datagrid('getChecked');
        if ($selected.length === 0) {
            layer.alert("请选择一条数据！");
            return;
        }
        WindowManager.closeLayer({
            returnValue: $selected
        });

    });

});

